clear;

load('comm_loc.mat');
num_new_branch(1:25)=0.0;
num_close_branch(1:25)=0.0;

for i=1:25
    num_new_branch(i)=sum((comm_loc(:,i+1)-comm_loc(:,i))==1);
    num_close_branch(i)=sum((comm_loc(:,i+1)-comm_loc(:,i))==-1);
end
num_net=num_new_branch-num_close_branch;


fig=figure('color', [1 1 1 ], 'Position',[200 20 800 360]);
plot(1987:1:2011, num_new_branch, '-b' , 'LineWidth', 2 );
hold on
plot(1987:1:2011,num_close_branch, '--k', 'Linewidth', 2);
hold on
plot(1987:1:2011,num_net, '-.r', 'Linewidth', 2);
grid on
xlabel('year', 'FontSize',12,'Interpreter','Latex');
ylabel('number of branches', 'FontSize',12,'Interpreter','Latex');
legend('number of new branches opened','number of branch closures','net change in the number of branches','interpreter','latex','location','northwest')

xlim([1987 2011]);
xticks(1987:5:2007);
ylim([-20 120]);
ax = gca;
% ax.YRuler.Exponent = 0;
set(gca,'FontSize',12);
